package a66weding.com.jiehuntong.anim;

import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.OvershootInterpolator;
import android.view.animation.Transformation;

/**
 * Created by admin on 2016/6/29.
 */
public class ResetHeightAnimation extends Animation {
    private String tag = ResetHeightAnimation.class.getSimpleName();
    private View view;
    private int targetHeight;

    private int originalHeight;
    private int totalValue;

    public ResetHeightAnimation(View view, int targetHeight) {
        super();
        this.view = view;
        this.targetHeight = targetHeight;
        originalHeight = view.getHeight();
        totalValue = targetHeight - originalHeight;

        setDuration(500);
        setInterpolator(new OvershootInterpolator());


    }
    /**
     * 会一直执行，知道动画完成
     * interpolatedTime : 0-1    标识动画执行的进度，或者百分比
     * 10 - 110    总长度：100
     * value:10+100*0.1  10+100*0.5
     * time: 0.1          0.5
     */
    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        super.applyTransformation(interpolatedTime, t);

        int newHeight = (int) (originalHeight + 3*totalValue);
        view.getLayoutParams().height = newHeight;
        view.requestLayout();

    }
}
